package com.hoshiicloud.payment.controller;

import com.hoshiicloud.common.rpc.Response;
import com.hoshiicloud.payment.Paylist;
import com.hoshiicloud.payment.param.*;
import com.hoshiicloud.payment.service.PayService;
import com.hoshiicloud.payment.vo.PayResponse;
import com.hoshiicloud.payment.vo.RefundResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@Api(value = "支付服务", tags = "支付服务")
@RestController
@Slf4j
@RequestMapping("/pay")
public class PayController {
    @Autowired
    private PayService payService;

    /**
     * @param param
     * @return com.hoshiicloud.common.rpc.Response
     * @description: 创建支付订单
     */
    @ApiOperation(value = "下单")
    @PostMapping("/order")
    public Response<PayResponse> order(@Valid @RequestBody PayRequest param) {
        return payService.order(param);
    }

    /**
     * @return com.hoshiicloud.common.rpc.Response
     * @author: Mr.wu
     * @descripton: 关闭订单 注意：订单生成后不能马上调用关单接口，最短调用时间间隔为5分钟。
     * @date: 17:28 2019/5/17
     */
    @ApiOperation(value = "关闭订单")
    @PostMapping("/closeOrder")
    public Response closeOrder(@RequestBody CloseOrderRequest param) {
        return payService.closeOrder(param);
    }

    @ApiOperation(value = "查询订单")
    @PostMapping("/queryOrder")
    public Response<Paylist> queryOrder(@Valid @RequestBody QueryOrderRequest param) {
        return payService.queryOrder(param);
    }

    @ApiOperation(value = "订单退款")
    @PostMapping(value = "/refund")
    public Response<RefundResponse> refundOrder(@RequestBody @Valid RefundRequest param) {
        return payService.refundOrder(param);
    }

    @ApiOperation(value = "查询退款订单")
    @PostMapping(value = "/queryRefund")
    public Response queryRefundOrder(@RequestBody QueryRefundRequest param) {
        return payService.queryRefundOrder(param);
    }
















    /**
     * @param param
     * @return com.hoshiicloud.common.rpc.Response
     * @description: 创建支付订单
     */
/*    @ApiOperation(value = "下单")
    @PostMapping("/order")
    public Response<PayResponse> order(@Valid @RequestBody PayRequest param) {
        return payService.order(param);*/
       /* try {
            log.info("支付服务下单逻辑开始");
            Response result = null;
            Channel channel = null;
            TreeMap<String ,String> paramMap = JSONObject.parseObject(JSON.toJSONString(param), new TypeReference<TreeMap<String, String>>(){});
            result=checkMer(param.getMerId().toString(),paramMap);
            if(!result.isSuccess()){
                return result;
            }

            result=checkOrder(param.getMerOrderId(),param.getMerId().toString());
            if(result.isSuccess()){
                return Response.failed("订单已存在");
            }

            result=checkMerConfig(param.getMerId().toString(),Channel.getByPayCode(param.getChannel()));
            if(!result.isSuccess()){
                return result;
            }
            Payment merPayment=(Payment) result.getData();
            //参数检查结束

            //获取订单号
            String orderId = idGeneratorService.queryGeneratorId();
            param.setOrderId(orderId);

            switch (param.getChannel()) {
                case "alipay":
                    break;
                case "weixin":
                    WeixinPayConfig payConfig= JSON.parseObject(merPayment.getPayConfig(), WeixinPayConfig.class);
                    WeixinConfig weixinConfig = new WeixinConfig(payConfig.getAppId(), payConfig.getMchId(),payConfig.getAppKey());
                    result = weixinPayService.order(param, weixinConfig);
                    channel = Channel.WEIXIN;
                    break;
                default:
                    return Response.failed("不支持的交易渠道");
            }
            if (result.isSuccess()) {
                PayBusinessResponse payData = (PayBusinessResponse) result.getData();
                Paylist paylist = new Paylist();
                paylist.setId(Long.valueOf(orderId));
                paylist.setOrderId(param.getMerOrderId());
                paylist.setUserid(Long.valueOf(param.getUserId()));
                paylist.setPlatformId(param.getMerId());
                //1消费 2退款
                paylist.setPayType(1);
                paylist.setPayOutderno(payData.getOutTradeNo());
                paylist.setPayamount(new BigDecimal(param.getAmount()).divide(new BigDecimal(100).setScale(2, RoundingMode.DOWN)));
                paylist.setStatus(0);
                paylist.setInAccount(payData.getSellerId());
                paylist.setOutAccount(param.getUserId());
                paylist.setChannel(channel.getChannel());
                //关联单号
                paylist.setRefno(param.getMerOrderId());

                if (paylistService.save(paylist)) {
                    //增加流水返回成功信息
                    PayResponse payResponse=new PayResponse();
                    BeanUtils.copyProperties(payData,payResponse);
                    payResponse.setOrderId(paylist.getId().toString());
                    if(PayConfig.processDebug &&PayConfig.debug){
                        return Response.success("测试流程成功,第三方接口返回信息:"+result.getMsg(),payResponse);
                    }
                    else{
                        return Response.data(payResponse);
                    }
                } else {
                    //添加流水失败
                    return Response.failed("添加支付流水失败");
                }

            } else {
                //下单失败
                return Response.failed(result.getMsg());
            }

            //下单成功添加支付流水
        } catch (ServiceException e) {
            return Response.failed(e.getError().getMsg());
        } catch (Exception e) {
            log.error("支付服务下单异常", e);
            return Response.failed("支付服务下单异常:"+e.getMessage());
        }*/
    /*}*/

    /**
     * @return com.hoshiicloud.common.rpc.Response
     * @author: Mr.wu
     * @descripton: 关闭订单 注意：订单生成后不能马上调用关单接口，最短调用时间间隔为5分钟。
     * @date: 17:28 2019/5/17
     */
/*    @ApiOperation(value = "关闭订单")
    @PostMapping("/closeOrder")
    public Response closeOrder(@RequestBody CloseOrderRequest param) {
        return payService.closeOrder(param);*/
       /* try {
            log.info("关闭订单逻辑开始");
            Response result = null;
            TreeMap<String ,String> paramMap = JSONObject.parseObject(JSON.toJSONString(param), new TypeReference<TreeMap<String, String>>(){});
            result=checkMer(param.getMerId(),paramMap);
            if(!result.isSuccess()){
                return result;
            }
            *//**
     * 如果已关闭直接返回成功
     * 如果未关闭则调用第三方支付接口的关闭订单，并更新订单状态
     *
     *//*

            //检查订单信息
            result=checkOrder(param.getMerOrderId(),param.getMerId());
            if(!result.isSuccess()){
                return result;
            }
            Paylist orderInfo=(Paylist) result.getData();



            //订单状态为未支付或支付异常时才可以关闭订单
            if (TradeStatus.getByStatus(orderInfo.getStatus()).equals(TradeStatus.NOTPAY) || TradeStatus.getByStatus(orderInfo.getStatus()).equals(TradeStatus.PAYERROR)) {
                //订单未成功,查询订单状态

                //检查商户配置信息
                result=checkMerConfig(param.getMerId(),Channel.getByChannel(orderInfo.getChannel()));
                if(!result.isSuccess()){
                    return result;
                }
                Payment merPayment=(Payment) result.getData();


                switch (Channel.getByChannel(orderInfo.getChannel())) {
                    case WEIXIN:
                        WeixinPayConfig payConfig= JSON.parseObject(merPayment.getPayConfig(), WeixinPayConfig.class);
                        WeixinConfig weixinConfig = new WeixinConfig(payConfig.getAppId(), payConfig.getMchId(),payConfig.getAppKey());
                        result = weixinPayService.closeOrder(param.getMerOrderId(), weixinConfig);
                        break;
                    case ALIPAY:
                        return Response.success("支付宝尚未实现");
                        //break;
                    default:
                        break;
                }
                if (result != null && result.isSuccess()) {
                    //关闭订单成功,根据第三方支付通道返回信息更新订单
                    orderInfo.setStatus(TradeStatus.CLOSED.getStatus());

                    paylistService.updateById(orderInfo);
                    return Response.success("关闭订单成功");
                }
                else if(PayConfig.processDebug && PayConfig.debug){
                    //流程测试
                    orderInfo.setStatus(TradeStatus.CLOSED.getStatus());

                    paylistService.updateById(orderInfo);
                    return Response.success("测试流程成功,第三方接口返回信息:"+result.toString());
                }
                else {
                    //关闭订单失败,返回错误
                    if (result == null) {
                        return Response.failed("调用第三方关闭订单接口失败");
                    } else {
                        return Response.failed(result.getMsg());
                    }
                }
            }
            else{
                return Response.success("订单已经是关闭状态");
            }
        } catch (ServiceException e) {
            return Response.failed(e.getError().getMsg());
        } catch (Exception e) {
            log.error("关闭订单异常", e);
            return Response.failed("关闭订单异常");
        }*/
    /*  }*/

   /* @ApiOperation(value = "查询订单")
    @PostMapping("/queryOrder")
    public Response<Paylist> queryOrder(@Valid @RequestBody QueryOrderRequest param) {
        return payService.queryOrder(param);*/
        /*try {
            log.info("查询订单逻辑开始");
            Response result = null;
            TreeMap<String ,String> paramMap = JSONObject.parseObject(JSON.toJSONString(param), new TypeReference<TreeMap<String, String>>(){});
            result=verificationReq(paramMap,true);
            if(!result.isSuccess()){
                return result;
            }

            *//**
     * 首先判断订单状态是否已经完成/关闭，如已完成直接返回
     * 如果订单为待支付状态，根据订单渠道调用第三方支付接口的查询订单
     * 根据返回结果更新订单状态并返回
     *//*
            Paylist orderInfo=(Paylist) result.getData();
            TradeStatus orderStatus=TradeStatus.getByStatus(orderInfo.getStatus());
            if(orderStatus.equals(TradeStatus.SUCCESS) || orderStatus.equals(TradeStatus.CLOSED) || orderStatus.equals(TradeStatus.REFUND) || orderStatus.equals(TradeStatus.FINISHED)){

            }
            else {
                //订单未成功,查询订单状态

                //获取商户配置
                QueryWrapper queryWrapper=new QueryWrapper();
                queryWrapper.eq("platformid",param.getMerId());
                queryWrapper.eq("pay_code",orderInfo.getChannel());
                Payment merPayment=paymentService.getOne(queryWrapper);
                if(merPayment==null){
                    return Response.failed("商户信息不存在，无法更新订单状态");
                }

                switch (Channel.getByChannel(orderInfo.getChannel())) {
                    case WEIXIN:
                        WeixinPayConfig payConfig= JSON.parseObject(merPayment.getPayConfig(), WeixinPayConfig.class);
                        WeixinConfig weixinConfig = new WeixinConfig(payConfig.getAppId(), payConfig.getMchId(),payConfig.getAppKey());
                        result = weixinPayService.queryOrder(param.getMerOrderId(), weixinConfig);
                        break;
                    case ALIPAY:
                        return Response.failed("支付宝尚未实现");
                        //break;
                    default:
                        break;
                }
                //流程测试,即使失败也返回
                if(PayConfig.processDebug && PayConfig.debug && !result.isSuccess()){
                    return Response.success("测试流程成功,第三方接口返回信息:"+result.toString(),orderInfo);
                }
                if (result != null && result.isSuccess()) {
                    //查询订单成功,根据第三方支付通道返回信息更新订单
                    QueryOrderBusinessResponse response = (QueryOrderBusinessResponse) result.getData();

                    if(response.getTradeStatus().equals(TradeStatus.SUCCESS)){
                        //支付成功处理,调用回调成功时的逻辑
                        CallBackRequest callBackRequest=new CallBackRequest(response.getTotalAmount(),response.getTradeNo(),response.getOutTradeNo(),response.getPayTime());
                        result= paylistService.paymentProcess(callBackRequest);
                        if(result.isSuccess()){
                            return Response.success("查询成功",(Paylist) result.getData());
                        }
                        else{
                            return result;
                        }
                    }
                    else{
                        orderInfo.setStatus(response.getTradeStatus().getStatus());
                        orderInfo.setUpdatedTime(LocalDateTime.now());
                        paylistService.updateById(orderInfo);
                    }
                } else {
                    //查询订单失败,返回错误
                    if (result == null) {
                        return Response.failed("调用第三方查询订单接口失败");
                    } else {
                        return Response.failed(result.getMsg());
                    }
                }
            }
            //返回订单信息
            return Response.data(orderInfo);
        } catch (ServiceException e) {
            return Response.failed(e.getError().getMsg());
        } catch (Exception e) {
            log.error("查询订单异常", e);
            return Response.failed("查询订单异常:"+e.getMessage());
        }*/
    /*}*/
   /* @ApiOperation(value = "订单退款")
    @PostMapping(value = "/aftersale")
    public Response<RefundResponse> aftersale(@Valid RefundRequest param){
        return payService.aftersale(param);*/
        /*try{
            log.info("退款逻辑开始");
            log.info("退款回调地址:"+PayConfig.getWeixinRefundNotity());
            Response result = null;
            Channel channel = null;
            TreeMap<String ,String> paramMap = JSONObject.parseObject(JSON.toJSONString(param), new TypeReference<TreeMap<String, String>>(){});
            result=checkMer(param.getMerId().toString(),paramMap);
            if(!result.isSuccess()){
                return result;
            }

            result=checkOrder(param.getMerOrderId(),param.getMerId().toString());
            if(!result.isSuccess()){
                return result;
            }
            Paylist orderInfo=(Paylist) result.getData();

            result=checkMerConfig(param.getMerId().toString(),Channel.getByChannel(orderInfo.getChannel()));
            if(!result.isSuccess()){
                return result;
            }
            Payment merPayment=(Payment) result.getData();
            //参数检查结束

            *//**
     * 根据商户订单号获取原支付流水数据
     * 发起退款请求并生成退款单号
     *//*

            //根据退款单号查询是否已退款
            QueryWrapper queryWrapper=new QueryWrapper();
            queryWrapper.eq("order_id",param.getRefundNo());
            queryWrapper.eq("platformid",param.getMerId());
            List<Paylist> list=paylistService.getByParam(queryWrapper);
            if(list.size()>0){
                //退款单已存在
                return Response.failed("退款单已存在");
            }

            //生成退款单号
            String refundId = idGeneratorService.queryGeneratorId();
            param.setRefundRealNo(refundId);

            String merOrderId=param.getMerOrderId();
            //重新设置meroderid为paylist的主键,因下单时使用主键传递给第三方
            param.setMerOrderId(orderInfo.getId().toString());

            switch (Channel.getByChannel(orderInfo.getChannel())){
                case WEIXIN:
                    WeixinPayConfig payConfig= JSON.parseObject(merPayment.getPayConfig(), WeixinPayConfig.class);
                    //获取证书文件
                    if(StringUtils.isBlank(payConfig.getCert())){
                        return Response.failed("请先配置证书");
                    }
                    //TODO 接口改为只需传入平台id，无需先获取存储空间名称
                    String bucketName="obs-7d37";
                    InputStream inputStream=certificateService.getCert(bucketName,payConfig.getCert());

                    WeixinConfig weixinConfig = new WeixinConfig(payConfig.getAppId(), payConfig.getMchId(),payConfig.getAppKey());
                    weixinConfig.setCertInputStream(inputStream);
                    result= weixinPayService.aftersale(param,weixinConfig);
                    break;
                case ALIPAY:
                    break;
                    default:
                        break;
            }

            if (result != null && result.isSuccess()) {
                //退款成功处理业务
                RefundBusinessResponse refundBusinessResponse=(RefundBusinessResponse) result.getData();
                Paylist paylist=new Paylist();
                paylist.setId(Long.valueOf(refundId));
                paylist.setUserid(orderInfo.getUserid());
                paylist.setPlatformId(param.getMerId());
                paylist.setOrderId(param.getRefundNo());
                paylist.setPayOrderno(orderInfo.getId().toString());
                paylist.setPayType(2);
                paylist.setPayOutderno(refundBusinessResponse.getOutRefundNo());
                //支付金额写入退款金额
                paylist.setPayamount(refundBusinessResponse.getRefundAmount());
                paylist.setAmount(refundBusinessResponse.getRefundAmount());
                paylist.setStatus(TradeStatus.NOTPAY.getStatus());
                paylist.setInAccount(orderInfo.getInAccount());
                paylist.setOutAccount(orderInfo.getOutAccount());
                paylist.setChannel(orderInfo.getChannel());
                //关联单号
                paylist.setRefno(param.getRefundNo());

                if (paylistService.save(paylist)) {
                    //增加流水返回成功信息
                    RefundResponse refundResponse=new RefundResponse();
                    refundResponse.setOutRefundNo(paylist.getOrderId());
                    refundResponse.setRefundNo(paylist.getId().toString());
                    refundResponse.setTotalAmount(refundBusinessResponse.getTotalAmount());
                    refundResponse.setRefundAmount(refundBusinessResponse.getRefundAmount());
                    if(PayConfig.processDebug &&PayConfig.debug){
                        return Response.success("测试流程成功,第三方接口返回信息:"+result.getMsg(),refundResponse);
                    }
                    else{
                        return Response.data(refundResponse);
                    }
                } else {
                    //添加流水失败
                    return Response.failed("添加支付流水失败");
                }

            } else {
                //订单退款失败,返回错误
                if (result == null) {
                    return Response.failed("调用第三方退款接口失败");
                } else {
                    return Response.failed(result.getMsg());
                }
            }

        }catch (Exception e){
            log.error("查询订单异常", e);
            return Response.failed("订单退款异常:"+e.getMessage());
        }*/
    /*}*/
   /* @ApiOperation(value = "查询退款订单")
    @PostMapping(value = "/queryRefund")
    public Response queryRefundOrder(QueryRefundRequest param){
        return payService.queryRefundOrder(param);*/
        /*try {
            log.info("查询退款订单逻辑开始");
            Response result = null;
            TreeMap<String ,String> paramMap = JSONObject.parseObject(JSON.toJSONString(param), new TypeReference<TreeMap<String, String>>(){});
            result=verificationReq(paramMap,true);
            if(!result.isSuccess()){
                return result;
            }

            *//**
     * 首先判断订单状态是否已经完成/关闭，如已完成直接返回
     * 如果订单为待支付状态，根据订单渠道调用第三方支付接口的查询订单
     * 根据返回结果更新订单状态并返回
     *//*
            Paylist orderInfo=(Paylist) result.getData();
            TradeStatus orderStatus=TradeStatus.getByStatus(orderInfo.getStatus());
            if(orderStatus.equals(TradeStatus.SUCCESS) || orderStatus.equals(TradeStatus.CLOSED) || orderStatus.equals(TradeStatus.REFUND) || orderStatus.equals(TradeStatus.FINISHED)){

            }
            else {
                //订单未成功,查询订单状态

                //获取商户配置
                QueryWrapper queryWrapper=new QueryWrapper();
                queryWrapper.eq("platformid",param.getMerId());
                queryWrapper.eq("pay_code",orderInfo.getChannel());
                Payment merPayment=paymentService.getOne(queryWrapper);
                if(merPayment==null){
                    return Response.failed("商户信息不存在，无法更新订单状态");
                }

                switch (Channel.getByChannel(orderInfo.getChannel())) {
                    case WEIXIN:
                        WeixinPayConfig payConfig= JSON.parseObject(merPayment.getPayConfig(), WeixinPayConfig.class);
                        WeixinConfig weixinConfig = new WeixinConfig(payConfig.getAppId(), payConfig.getMchId(),payConfig.getAppKey());
                        result = weixinPayService.queryRefundOrder(orderInfo.getId().toString(), weixinConfig);
                        break;
                    case ALIPAY:
                        return Response.failed("支付宝尚未实现");
                    //break;
                }
                //流程测试,即使失败也返回
                if(PayConfig.processDebug && PayConfig.debug && !result.isSuccess()){
                    return Response.success("测试流程成功,第三方接口返回信息:"+result.toString(),orderInfo);
                }
                if (result != null && result.isSuccess()) {
                    //查询订单成功,根据第三方支付通道返回信息更新订单
                    QueryOrderBusinessResponse response = (QueryOrderBusinessResponse) result.getData();

                    if(response.getTradeStatus().equals(TradeStatus.SUCCESS)){
                        //退款成功处理,调用回调成功时的逻辑
                        CallBackRequest callBackRequest=new CallBackRequest(response.getPayAmount(),response.getTradeNo(),response.getOutTradeNo(),response.getPayTime());
                        result= paylistService.paymentProcess(callBackRequest);
                        if(result.isSuccess()){
                            return Response.success("查询成功",(Paylist) result.getData());
                        }
                        else{
                            return result;
                        }
                    }
                    else{
                        orderInfo.setStatus(response.getTradeStatus().getStatus());
                        orderInfo.setUpdatedTime(LocalDateTime.now());
                        paylistService.updateById(orderInfo);
                    }
                } else {
                    //查询订单失败,返回错误
                    if (result == null) {
                        return Response.failed("调用第三方查询退款订单接口失败");
                    } else {
                        return Response.failed(result.getMsg());
                    }
                }
            }
            //返回订单信息
            return Response.data(orderInfo);
        } catch (ServiceException e) {
            return Response.failed(e.getError().getMsg());
        } catch (Exception e) {
            log.error("查询退款订单异常", e);
            return Response.failed("查询退款订单异常:"+e.getMessage());
        }*/
    /* }*/




     /*private Response<Paylist> checkOrder(String orderId,String merId){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("order_id", orderId);
        queryWrapper.eq("platformid",merId);
        List<Paylist> list = paylistService.getByParam(queryWrapper);
        if (list == null || list.size()==0) {
            return Response.failed("订单不存在");
        }
        else if(list.size()>1){
            //TODO 存在重复订单，抛出异常
        }
        return Response.data(list.get(0));
    }

    private Response<Platform> checkMer(String merId,TreeMap<String ,String> paramMap){
        Platform platform=platformService.getById(Long.valueOf(merId)).getData();
        if(platform==null){
            //return Response.failed("商户信息不存在");
            throw new ServiceException("商户信息不存在");
        }

        //测试配置
        platform.setSecretKey("098f6bcd4621d373cade4e832627b4f6");
        if(StringUtils.isBlank(platform.getSecretKey())){
            //return Response.failed("商户信息未配置");
            throw new ServiceException("商户信息未配置");
        }
        //签名验证
        if(!TensoonUtil.checkSign(paramMap,platform.getSecretKey())){
            if(PayConfig.processDebug){
                //return Response.failed("签名错误,流程测试下返回正确签名值:"+TensoonUtil.sign(paramMap,platform.getSecretKey()));
                throw new ServiceException("签名错误,流程测试下返回正确签名值:"+TensoonUtil.sign(paramMap,platform.getSecretKey()));
            }
            //return Response.failed("签名错误");
            throw new ServiceException("签名错误");
        }

        return Response.data(platform);
    }

    private Response<Payment> checkMerConfig(String merId,Channel channel){
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("platformid",merId);
        queryWrapper.eq("pay_code",channel.getPayCode());

        Payment config=paymentService.getOne(queryWrapper);
        if(config==null || StringUtils.isBlank(config.getPayConfig())){
            //return Response.failed("商户支付信息未配置");
            throw new ServiceException("商户支付信息未配置");
        }
        return Response.data(config);
    }

    *//**
     * @param paramMap
     * @param isCheckOrder 是否验证订单
     * @return com.hoshiicloud.common.rpc.Response
     * @author: Mr.wu
     * @descripton: 验证
     * @date: 19:36 2019/5/27
     *//*
    private Response verificationReq(TreeMap<String ,String> paramMap,boolean isCheckOrder){
        String orderId= paramMap.get("merOrderId");
        String merId=paramMap.get("merId");
        String payCode=paramMap.get("channel");
        Channel channel=null;

        QueryWrapper queryWrapper = null;
        Paylist orderInfo=null;
        Response result=null;
        if(isCheckOrder){
            result= checkOrder(orderId,merId);
            if(!result.isSuccess()){
                return result;
            }
            //根据数字类型获得枚举再获得paycode值
            orderInfo=(Paylist) result.getData();
            channel=Channel.getByChannel(orderInfo.getChannel());
        }
        else{
            channel=Channel.getByPayCode(payCode);
        }
        //检查商户信息
        result=checkMer(merId,paramMap);
        if(!result.isSuccess()){
            return result;
        }
        //检查商户配置信息
        result=checkMerConfig(merId,channel);
        if(!result.isSuccess()) {
            return result;
        }
        //检查订单的情况下,如果验证成功返回订单信息
        if(isCheckOrder){
            return Response.data(orderInfo);
        }
        return Response.success("验证通过");
    }*/
}
